package com.jindi.appplan;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * User: duanj
 * Date: 2017-12-22
 * Time: 17:13
 * Description:
 */
public class permutate {
    public static int total = 0;

    public static void swap(String[] str, int i, int j) {
        String temp = new String();
        temp = str[i];
        str[i] = str[j];
        str[j] = temp;
    }

    public static void arrange(String[] str, int st, int len) {
        if (st == len - 1) {
            for (int i = 0; i < len; i++) {
                System.out.print(str[i] + "  ");
            }
            System.out.println();
            total++;
        } else {
            for (int i = st; i < len; i++) {
                swap(str, st, i);
                arrange(str, st + 1, len);
                swap(str, st, i);
            }
        }

    }

    /**
     * @param args
     */
    public static void main(String[] args) {
        int max = 10;
        int min = 0;

        List<String> list = new ArrayList<>();
        List<String> list1 = new ArrayList<>();
        for (int j = 0; j < 6; j++) {
            String d = "";//
            int b = 0;
            int c = 0;
            String f = "";
            for (int i = 0; i < 3; i++) {
                int a = (int) (Math.random() * (max - min)) + min;
                if (a % 2 == 0) {
                    b++;
                } else {
                    c++;
                }
            }
            if (c == 3) {
                d = "1";
                f = "老阳——x";
            } else if (b == 3) {
                d = "0";
                f = "老阴——x";
            } else if (b < c) {
                d = "1";
                f = "少阳——";
            } else if (b > c) {
                d = "0";
                f = "少阴--";
            }
            list.add(f);
            list1.add(d);
        }

        System.out.println("正卦");
        Collections.reverse(list);
        Collections.reverse(list1);
        for (String s : list) {
            System.out.println(s);
        }
        makeGua(list1);

    }

    //是乾卦、兑卦、离卦、震卦、巽卦、坎卦、艮卦、坤卦
   static void makeGua(List<String > list){
        String [] a = {"坤","艮","坎","巽","震","离","兑","乾",};
       String [] a1 = {"000","100","010","110","001","101","011","111",};
       Map<String,String > map = new HashMap();
       for (int i=0;i<8;i++) {
           map.put(a1[i],a[i]);
       }
       String up =  list.get(0)+list.get(1)+list.get(2);
       String down =  list.get(3)+list.get(4)+list.get(5);
       System.out.println(up);
       System.out.println(down);
       up = map.get(up);
       down = map.get(down);
       System.out.println(up);
       System.out.println(down);
       System.out.println("上"+up+"下"+down);
   }


}
